package org.tong.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.tong.beans.Student;
import org.tong.repository.StudentJpa;

import java.util.Optional;


/**
 * @author
 * @date 2022-11-15 19:30
 */
@Service
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public class StudentFinder {

    @Autowired
    private StudentJpa studentJpa;

    public Student getById(Long id) {
        return studentJpa.findById(id).orElseThrow(()->new RuntimeException("数据不存在"));
    }
}
